﻿using StateMachine;
using System;

namespace WpfClient.FunctionFileParsing
{
    public abstract class FunctionFileParsingStateHandlerBase : StateHandler<FunctionFileParsingState>
    {
        private readonly FunctionFileParserContext parserContext;

        public FunctionFileParsingStateHandlerBase(FunctionFileParserContext context)
            : base(context)
        {
            this.parserContext = context;
        }

        protected FunctionFileParserContext ParserContext
        {
            get
            {
                return this.parserContext;
            }
        }

        protected sealed override FunctionFileParsingState HandleInputOverride(object input)
        {
            char symbol = (char)input;

            this.ParserContext.Buffer.Append(symbol);
            return this.Handle(symbol);
        }

        protected abstract FunctionFileParsingState Handle(char symbol);
    }
}
